package com.gouwudai.gobbs.dao.impl;

import org.apache.log4j.Logger;

import com.gouwudai.gobbs.common.IPageList;
import com.gouwudai.gobbs.dao.IAdDAO;
import com.gouwudai.gobbs.pojo.TbbsAd;
import com.litt.core.common.PageParam;

/**
 * 
 * <pre>
 *  Title:广告信息DAO
 *  Description: 广告信息DAO  
 * </pre>
 * 
 * @author <a href="mailto:littcai@hotmail.com">空心大白菜</a>
 * @date 2007-3-29
 * @version 1.0
 * <pre>
 * 修改记录
 *    修改后版本:     修改人：  修改日期:     修改内容: 
 * </pre>
 */
public class AdDAOImpl extends BaseDAOImpl implements IAdDAO 
{
	private static final Logger logger = Logger.getLogger(AdDAOImpl.class);	
	private static final String BUSI_NAME = "广告信息";
	
	public Integer save(TbbsAd tbbsAd)
	{
        return super.saveObject(tbbsAd);		
	}
	
	public TbbsAd load(Integer id)
	{
		return (TbbsAd)super.loadObject(TbbsAd.class, id);
	}   
    
    public void update(TbbsAd tbbsAd)
    {
//        StringBuilder hql = new StringBuilder();
//        hql.append("update TbbsAd set title=?");
//        hql.append(", url=?");
//        hql.append(", width=?");
//        hql.append(", height=?");
//        hql.append(", type=?");
//        hql.append(", content=?");
//        hql.append(" where adId=?");
//        super.updateObject(hql.toString(), new Object[]{
//        	tbbsAd.getTitle(),
//        	tbbsAd.getUrl(),
//        	tbbsAd.getWidth(),
//        	tbbsAd.getHeight(),
//        	tbbsAd.getType(),
//        	tbbsAd.getContent(),
//        	tbbsAd.getAdId()});
        super.updateObject(tbbsAd);
    }

    public void delete(Integer adId)
    {
        super.deleteObject(TbbsAd.class.getName(),"adId",adId);
    }

    public IPageList listPage(PageParam pageParam)
    {	
    	StringBuilder listSql = new StringBuilder("SELECT A.*,B.DICT_CONTENT AS TYPE_NAME FROM TbbsAd A,TbbsDictParam B WHERE B.DICT_TYPE='A001' AND A.TYPE=B.DICT_VALUE"); 	
    	return super.listSqlPage(listSql.toString(),pageParam.getPageIndex(),pageParam.getPageSize());
    }   
    
}
